package net.sk.china.platform.web;

import io.swagger.annotations.*;
import net.sk.china.platform.service.wechat.WechatMediaService;
import net.sk.china.common.response.CommonResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * +----------------------------------------------------------------------
 * | Talk To [ 聊来改善地区金融服务环境，助力企业发展 ]
 * +----------------------------------------------------------------------
 * | Copyright (c) 2018-2024 聊来All rights reserved.
 * +----------------------------------------------------------------------
 * | Licensed ( <a href="http://www.apache.org/licenses/LICENSE-2.0">apache</a> )
 * +----------------------------------------------------------------------
 * | @Author: 聊来 <18970881148@qq.com>
 * +----------------------------------------------------------------------
 * | DateTime: 2024/6/2 22:10
 * +----------------------------------------------------------------------
 */

@RestController
@RequestMapping("wechat/media/")
@Api(tags = "微信开放平台 -- 素材")
public class WechatMediaController {

    private final WechatMediaService wechatMediaService;

    public WechatMediaController(WechatMediaService wechatMediaService) {
        this.wechatMediaService = wechatMediaService;
    }

    /**
     * 上传
     */

    @ApiOperation(value = "上传")
    @RequestMapping(value = "upload", method = RequestMethod.POST)
    @ApiImplicitParam(name = "type", value = "媒体文件类型，分别有图片（image）、语音（voice)", dataTypeClass = String.class)
    public CommonResult<Map<String, String>> upload(MultipartFile file, @RequestParam(value = "type") String type) {
        return CommonResult.success(wechatMediaService.upload(file, type));
    }
}
